package Demo.Test1;

import java.util.Arrays;
import java.util.Comparator;


public class Test02 {
    public static void main(String[] args) {
        int[] cards = {3,22,11,100,5486,86};
        Long maxNumber = getMaxNumber(cards);
        System.out.println("最大数字是: " + maxNumber);
    }
    
    public static Long getMaxNumber(int[] cards) {
        String[] cardStrings = Arrays.stream(cards).mapToObj(String::valueOf).toArray(String[]::new);
        
        Arrays.sort(cardStrings, new Comparator<String>() {
            @Override
            public int compare(String a, String b) {
                return (b + a).compareTo(a + b);
            }
        });

        Arrays.stream(cardStrings).forEach(System.out::println);
        
        StringBuilder sb = new StringBuilder();
        for (String cardString : cardStrings) {
            sb.append(cardString);
        }
        
        return Long.parseLong(sb.toString());
    }
}